package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
 * 基于字符转换流从文件读取字符数据
 */
public class InputStreamReaderDemo01 {
    public static void main(String[] args) throws IOException {
        //1.创建字符输入转换流对象
        InputStreamReader isr = new InputStreamReader(
                new FileInputStream("./osw.txt"), StandardCharsets.UTF_8);
        //2.读数据
        int data=0;
        while((data=isr.read())!=-1){
            System.out.print((char)data);
        }
        //3.关闭流对象
        isr.close();
    }
}
